home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.7z / ftp.whtech.com / emulators / mess / MESS 0.133 / Macintosh / MessMenu 0.7.0 OSX uni.dmg / MessMenu.app / Contents / MacOS / prefs.tcl < prev    next >
Encoding:
Text File  |  2008-09-29  |  4.4 KB  |  161 lines

  1. option add *Listbox*font \
  2.     "-*-helvetica-medium-r-normal-*-12-*-*-*-p-*-iso8859-1" startupFile
  3. option add *Entry*font \
  4.     "-*-helvetica-medium-r-normal-*-12-*-*-*-p-*-iso8859-1" startupFile
  5. option add *Label*font \
  6.     "-*-helvetica-medium-r-normal-*-12-*-*-*-p-*-iso8859-1" startupFile
  7.  
  8. # this is the default proc  called when "OK" is pressed
  9. # indicate your own proc as an argument to prefs
  10.  
  11. set windowed 0
  12. set throttle 0
  13. set vmode "opengl"
  14.  
  15. proc prefs.default.cmd {f} {
  16.     global prefs
  17.     destroy $w
  18. }
  19.  
  20.  
  21. # this is the default proc called when error is detected
  22. # indicate your own proc as an argument to prefs
  23.  
  24. proc prefs.default.errorHandler {errorMessage} {
  25.     puts stdout "error: $errorMessage"
  26.     catch { cd ~ }
  27. }
  28.  
  29. # this is the proc that creates the prefs window
  30.  
  31. proc prefs {
  32.     {cmd prefs.default.cmd} 
  33.     {w .prefsWindow} 
  34.     {errorHandler prefs.default.errorHandler}} {
  35.     global windowed
  36.     global throttle
  37.     global vmode
  38.     catch {destroy $w}
  39.  
  40.     toplevel $w
  41.     grab $w
  42.     wm title $w "Preferences"
  43.  
  44.     set fl [open "| ./uimodeidx.sh"]
  45.     gets $fl cur_uimodeidx
  46.     if {[catch {close $fl} err]} {
  47.     puts "Failed to read current ui mode key: $err"
  48.     }
  49.     set fl [open "| ./getoption.sh window"]
  50.     gets $fl cur_window
  51.     if {[catch {close $fl} err]} {
  52.     puts "Failed to read current window mode: $err"
  53.     }
  54.     set fl [open "| ./getoption.sh throttle"]
  55.     gets $fl cur_throttle
  56.     if {[catch {close $fl} err]} {
  57.     puts "Failed to read current throttle setting: $err"
  58.     }
  59.     set fl [open "| ./getoption.sh video"]
  60.     gets $fl cur_video
  61.     if {[catch {close $fl} err]} {
  62.     puts "Failed to read current video setting: $err"
  63.     }
  64.  
  65.  
  66.     # path independent names for the widgets
  67.     global prefs
  68.     set prefs(uikeylst) $w.prefs.sframe.uikeylst 
  69.     set prefs(scroll) $w.prefs.sframe.scroll
  70.     set prefs(ok) $w.bframe.okframe.ok
  71.  
  72.     # widgets
  73.     frame $w.prefs -bd 5
  74.     frame $w.bframe -bd 5
  75.     pack append $w \
  76.         $w.prefs {top filly} \
  77.         $w.bframe {bottom expand frame n}
  78.  
  79.     frame $w.prefs.sframe
  80.  
  81.     pack append $w.prefs \
  82.     $w.prefs.sframe {top fillx}
  83.  
  84.     label $w.prefs.sframe.uikeylab -text "Select UI Mode key"
  85.     listbox $w.prefs.sframe.uikeylst -relief sunken -selectmode single \
  86.         -yscroll "$w.prefs.sframe.yscroll set"
  87.     scrollbar $w.prefs.sframe.yscroll -relief sunken \
  88.      -command "$w.prefs.sframe.uikeylst yview"
  89.     source uikeylst.tcl
  90.     $w.prefs.sframe.uikeylst selection set $cur_uimodeidx
  91.     $w.prefs.sframe.uikeylst see $cur_uimodeidx
  92.     pack append $w.prefs.sframe \
  93.     $w.prefs.sframe.uikeylab {top} \
  94.         $w.prefs.sframe.yscroll {right filly} \
  95.      $w.prefs.sframe.uikeylst {left expand fill}
  96.  
  97.     # buttons
  98.     frame $w.bframe.okframe -borderwidth 2
  99.  
  100.     label $w.bframe.okframe.vlab -text "Video mode"
  101.     set vvalues [list]
  102.     lappend vvalues "opengl"
  103.     lappend vvalues "soft"
  104.     spinbox $w.bframe.okframe.vmode -textvariable vmode -values $vvalues
  105.     set vmode $cur_video
  106.  
  107.     checkbutton $w.bframe.okframe.win -text "Run in a window" -variable windowed
  108.     if {$cur_window==1} {
  109.     $w.bframe.okframe.win select
  110.     }
  111.     checkbutton $w.bframe.okframe.throt -text "Throttle" -variable throttle
  112.     if {$cur_throttle==1} {
  113.     $w.bframe.okframe.throt select
  114.     }
  115.     button $w.bframe.okframe.ok -text OK -relief raised \
  116.         -command "prefs.ok.cmd $w $cmd $errorHandler"
  117.  
  118.     pack append $w.bframe.okframe \
  119.     $w.bframe.okframe.vlab {top} \
  120.     $w.bframe.okframe.vmode {top} \
  121.     $w.bframe.okframe.win {top} \
  122.     $w.bframe.okframe.throt {top} \
  123.     $w.bframe.okframe.ok {bottom}
  124.  
  125.     pack append $w.bframe $w.bframe.okframe {expand padx 5 pady 5}
  126.  
  127. }
  128.  
  129.  
  130. # auxiliary button procedures
  131.  
  132. proc prefs.ok.cmd {w cmd errorHandler} {
  133.     global prefs
  134.     global windowed
  135.     global throttle
  136.     global vmode
  137.     global MESSHOME
  138.     global messdir
  139.     set uimodenum [$prefs(uikeylst) curselection]
  140.     set uimodekey [$prefs(uikeylst) get $uimodenum]
  141.     set currdir [pwd]
  142.     if [catch {exec ./resetini.sh} errors] {
  143.     tk_messageBox -default ok -message "Error running shell script" -type ok
  144.     }
  145.     cd "$MESSHOME"
  146.     set command "exec '$messdir/mess' -uimodekey $uimodekey -video $vmode"
  147.     if {$windowed==1} {
  148.     set command "$command -window"
  149.     }
  150.     if {$throttle==1} {
  151.     set command "$command -throttle"
  152.     }
  153.     set command "$command -createconfig"
  154.     puts $command
  155.     if [catch {exec /bin/sh -c $command} errors] {
  156.     tk_messageBox -default ok -message "Error running \"$command\"" -type ok
  157.     }
  158.     cd "$currdir"
  159.     destroy $w
  160. }
  161.